<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<script type="text/javascript">
	$(function(){
		$("tr:even").css("backgroundColor","#6f6f6f");
	});
	function check() {
		$("table").html("<tr><th>宠物昵称</th><th>出生日期</th><th>性别</th></tr>");
		var breed=$("#breed").val();
		$.getJSON("ExitsSetvlet","breed="+breed,function(data){
			for (var i = 0; i < data.length; i++) {
				var sex=data[i].sex==1?"雄":"雌";
				$("table").append("<tr><td>"+data[i].name+"</td><td>"
						+data[i].birthday+"</td><td>"+sex+"</td>");
			}
		});
	}
</script>
<c:if test="${empty list }">
<c:redirect url="PetListServlet"></c:redirect>
</c:if>
</head>
<body>
<center>
<form action="" method="post">
	品种<select id="breed">
		<option value="0">请选择</option>
		<option value="1">狗</option>
		<option value="2">猫</option>
		<option value="3">鸟</option>
		<option value="4">兔</option>
	</select>
	<input type="button" value="查询" onclick="check();">&nbsp;&nbsp;&nbsp;
	<a href="AddPet.jsp">新增宠物</a>
</form>
<table border="1">
	<tr>
		<th>宠物昵称</th>
		<th>出生日期</th>
		<th>性别</th>
	</tr>
	<c:forEach items="${list }" var="temp">
	<tr>
		<td>${temp.name }</td>
		<td>${temp.birthday }</td>
		<td><c:if test="${temp.sex==1}">雄</c:if><c:if test="${temp.sex==2}">雌</c:if></td>
	</tr>
	</c:forEach>
</table>
</center>
</body>
</html>